import { useState } from 'react';
import service from './service/index.js';
import { ACCESS_TOKEN, REFRESH_TOKEN } from './config/constant';

const App = () => {
  const [data1, setData1] = useState();
  const [data2, setData2] = useState();
  const getData = () => {
    service.get('/getData').then((res) => {
      setData1(res.data.id);
    });
    service.get('/getData2').then((res) => {
      setData2(res.data.id);
    });
  };
  const getToken = () => {
    service.get('/login').then((res) => {
      //存储长token
      localStorage.setItem(REFRESH_TOKEN, res.refreshToken);
      //存储短token
      localStorage.setItem(ACCESS_TOKEN, res.accessToken);
    });
  };
  return (
    <div>
      {data1}--{data2}
      <button onClick={getData}>按钮</button>
      <button onClick={getToken}>登录</button>
    </div>
  );
};
export default App;